package com.luckyframe.project.jmeter.jmeterPlanCaseRel.controller;

import com.luckyframe.common.utils.poi.ExcelUtil;
import com.luckyframe.framework.aspectj.lang.annotation.Log;
import com.luckyframe.framework.aspectj.lang.enums.BusinessType;
import com.luckyframe.framework.web.controller.BaseController;
import com.luckyframe.framework.web.domain.AjaxResult;
import com.luckyframe.framework.web.page.TableDataInfo;
import com.luckyframe.project.jmeter.jmeterPlanCaseRel.domain.JmeterPlanCaseRel;
import com.luckyframe.project.jmeter.jmeterPlanCaseRel.service.IJmeterPlanCaseRelService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * jmx测试计划 用来中间 信息操作处理
 * 
 * @author lancelot
 * @date 2020-10-09
 */
@Controller
@RequestMapping("/jmeter/jmeterPlanCaseRel")
public class JmeterPlanCaseRelController extends BaseController
{
    private String prefix = "jmeter/jmeterPlanCaseRel";
	
	@Autowired
	private IJmeterPlanCaseRelService jmeterPlanCaseRelService;
	
	@RequiresPermissions("jmeter:jmeterPlanCaseRel:view")
	@GetMapping()
	public String jmeterPlanCaseRel()
	{
	    return prefix + "/jmeterPlanCaseRel";
	}
	
	/**
	 * 查询jmx测试计划 用来中间列表
	 */
	@RequiresPermissions("jmeter:jmeterPlanCaseRel:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(JmeterPlanCaseRel jmeterPlanCaseRel)
	{
		startPage();
        List<JmeterPlanCaseRel> list = jmeterPlanCaseRelService.selectJmeterPlanCaseRelList(jmeterPlanCaseRel);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出jmx测试计划 用来中间列表
	 */
	@RequiresPermissions("jmeter:jmeterPlanCaseRel:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JmeterPlanCaseRel jmeterPlanCaseRel)
    {
    	List<JmeterPlanCaseRel> list = jmeterPlanCaseRelService.selectJmeterPlanCaseRelList(jmeterPlanCaseRel);
        ExcelUtil<JmeterPlanCaseRel> util = new ExcelUtil<JmeterPlanCaseRel>(JmeterPlanCaseRel.class);
        return util.exportExcel(list, "jmeterPlanCaseRel");
    }
	
	/**
	 * 新增jmx测试计划 用来中间
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存jmx测试计划 用来中间
	 */
	@RequiresPermissions("jmeter:jmeterPlanCaseRel:add")
	@Log(title = "jmx测试计划 用来中间", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(JmeterPlanCaseRel jmeterPlanCaseRel)
	{		
		return toAjax(jmeterPlanCaseRelService.insertJmeterPlanCaseRel(jmeterPlanCaseRel));
	}

	/**
	 * 修改jmx测试计划 用来中间
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap)
	{
		JmeterPlanCaseRel jmeterPlanCaseRel = jmeterPlanCaseRelService.selectJmeterPlanCaseRelById(id);
		mmap.put("jmeterPlanCaseRel", jmeterPlanCaseRel);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存jmx测试计划 用来中间
	 */
	@RequiresPermissions("jmeter:jmeterPlanCaseRel:edit")
	@Log(title = "jmx测试计划 用来中间", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(JmeterPlanCaseRel jmeterPlanCaseRel)
	{		
		return toAjax(jmeterPlanCaseRelService.updateJmeterPlanCaseRel(jmeterPlanCaseRel));
	}
	
	/**
	 * 删除jmx测试计划 用来中间
	 */
	@RequiresPermissions("jmeter:jmeterPlanCaseRel:remove")
	@Log(title = "jmx测试计划 用来中间", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(jmeterPlanCaseRelService.deleteJmeterPlanCaseRelByIds(ids));
	}
	
}
